package handler

import (
	"github.com/gin-gonic/gin"
	"golang-websocket-chatroom/api/request"
	"golang-websocket-chatroom/internal/dao"
	"golang-websocket-chatroom/internal/model"
	"net/http"
)

func ChatList(c *gin.Context) {
	var req request.ChatListReq
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(http.StatusOK, gin.H{
			"code": 10000,
			"msg":  "验证失败",
			"data": err.Error(),
		})
		return
	}
	chat := model.Chat{
		Id:     2,
		People: "用户2",
		Test:   req.Test,
		Img:    "2",
	}
	dao.Chat(req.Test)
	c.JSON(http.StatusOK, gin.H{
		"code": 200,
		"msg":  "关键词筛选成功",
		"data": chat,
	})
}
